import java.util.ArrayList;
import java.util.List;

import com.lili.task.TaskSchedulerException;

public class Student implements Comparable{
    /**
     * 测试
     * @param args
     * @throws TaskSchedulerException
     */
    public static void main(String[] args) throws Exception {

        Student [] ss = new Student[6];

        ss[0] = new Student();
        ss[0].setId("100");
        ss[0].setName("张一");
        ss[0].setStature(180.1f);

        ss[1] = new Student();
        ss[1].setId("200");
        ss[1].setName("张三");
        ss[1].setStature(170.0f);

        ss[2] = new Student();
        ss[2].setId("100");
        ss[2].setName("张二");
        ss[2].setStature(179.3f);

        ss[3] = new Student();
        ss[3].setId("300");
        ss[3].setName("张三");
        ss[3].setStature(190.1f);

        ss[4] = new Student();
        ss[4].setId("400");
        ss[4].setName("张四");
        ss[4].setStature(170.1f);

        ss[5] = new Student();
        ss[5].setId("500");
        ss[5].setName("张五");
        ss[5].setStature(168.1f);

        System.out.println("--------排序前---------"+"\n"+java.util.Arrays.asList(ss).toString());

        java.util.Arrays.sort(ss);
        System.err.println("--------排序后---------"+"\n"+java.util.Arrays.asList(ss).toString());
    }

    //学号
    private String id;
    //姓名
    private String name;
    //身高
    private float stature;

    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public float getStature() {
        return stature;
    }
    public void setStature(float stature) {
        this.stature = stature;
    }
    /**
     * 重写 对象比较大小方法
     */
    public int compareTo(Object o) {
        if(o instanceof Student){
            if(o == null){
                return 1;
            }else{
                float f = this.stature -((Student)o).getStature();
                return (f>0 ? 1 : f ==0 ? 0 : -1);
            }
        }
        return 0;
    }

    public String toString() {

        return "{ 学号:"+this.id+" , 姓名:"+this.name+" , 身高:"+this.stature+" }";
    }

}